package com.yanmaohu.yulia.statement;

import com.yanmaohu.yulia.bean.*;

/**
 * @author Bright Lee
 */
public final class TriggerDefinition implements SchemaElement, SqlSchemaDefinitionStatement, Statement {

    private int beginIndex;
    private int endIndex;
    private SchemaQualifiedName triggerName;
    private TriggerActionTime triggerActionTime;
    private TriggerEvent triggerEvent;
    private LocalOrSchemaQualifiedName tableName;
    private OldOrNewValuesAliasList oldOrNewValuesAliasList;
    private TriggeredAction triggeredAction;

    public TriggerDefinition(int beginIndex,
                             SchemaQualifiedName triggerName,
                             TriggerActionTime triggerActionTime,
                             TriggerEvent triggerEvent,
                             LocalOrSchemaQualifiedName tableName,
                             OldOrNewValuesAliasList oldOrNewValuesAliasList,
                             TriggeredAction triggeredAction) {
        this.beginIndex = beginIndex;
        this.endIndex = triggeredAction.getEndIndex();
        this.triggerName = triggerName;
        this.triggerActionTime = triggerActionTime;
        this.triggerEvent = triggerEvent;
        this.tableName = tableName;
        this.oldOrNewValuesAliasList = oldOrNewValuesAliasList;
        this.triggeredAction = triggeredAction;
    }

    @Override
    public int getBeginIndex() {
        return beginIndex;
    }

    @Override
    public int getEndIndex() {
        return endIndex;
    }

    public SchemaQualifiedName getTriggerName() {
        return triggerName;
    }

    public TriggerActionTime getTriggerActionTime() {
        return triggerActionTime;
    }

    public TriggerEvent getTriggerEvent() {
        return triggerEvent;
    }

    public LocalOrSchemaQualifiedName getTableName() {
        return tableName;
    }

    public OldOrNewValuesAliasList getOldOrNewValuesAliasList() {
        return oldOrNewValuesAliasList;
    }

    public TriggeredAction getTriggeredAction() {
        return triggeredAction;
    }

}
